<template>
    <PageTabelLayout>
        <template #pageHeader>
            <div class="search-form" v-if="pageData.headerShow">
                <a-form size="mini" :model="pageData" layout="inline">
                    <a-form-item label="仓库类型">
                        <a-select popup-container="html"  class="bacClass" :style="{ width: '10rem' }" @change="whChange" placeholder=""
                            v-model="searchData.whTypeName" allow-clear>
                            <a-option v-for="item in whTypeList" :value="item.typeName">
                                {{ item.typeName }}
                            </a-option>
                        </a-select>
                    </a-form-item>
                    <a-form-item label="选择公司">
                        <a-select popup-container="html"  class="bacClass" :style="{ width: '10rem' }" @change="companyChange" placeholder=""
                            v-model="searchData.firm" allow-clear>
                            <a-option v-for="item in companyList" :value="item.id">
                                {{ item.typeName ? item.typeName + '-' + item.firmName : item.firmName }}
                            </a-option>
                        </a-select>
                    </a-form-item>
                    <a-form-item label="仓库">
                        <!-- @change="isWhilist" -->
                        <a-select popup-container="html"  @change="isWhilist" class="bacClass" :style="{ width: '10rem' }" placeholder=""
                            v-model="searchData.wh" @click="ckisPd" allow-clear>
                            <a-option v-for="item in whList" :value="item.warehouseName">
                                {{ item.warehouseName }}
                            </a-option>
                        </a-select>
                    </a-form-item>
                    <a-form-item label="领料单号" v-if="tabKey == 1">
                        <a-input class="bacClass" v-model="pageData.code" />
                    </a-form-item>
                    <a-form-item label="物料名称" v-if="tabKey == 1">
                        <a-input class="bacClass" v-model="pageData.materialName" />
                    </a-form-item>
                    <a-form-item label="需求时间" v-if="tabKey == 1">
                        <a-range-picker  popup-container="html"  class="bacClass" style="width: 254px;" v-model="pageData.requisitionTime" />
                    </a-form-item>


                    <a-form-item label="出库状态" v-if="tabKey == 2">
                        <a-select popup-container="html"  class="bacClass" :style="{ width: '10rem' }" placeholder="" v-model="searchData.stats"
                            allow-clear>
                            <a-option :value="0">待出库</a-option>
                            <a-option :value="1">已出库</a-option>
                        </a-select>
                    </a-form-item>
                </a-form>
            </div>
            <div class="my-divisders">
                <a-divider orientation="center">
                    <icon-double-up v-if="pageData.headerShow" @click="pageData.headerShow = false" :strokeWidth="2"
                        :size="18" />
                    <icon-double-down v-else @click="pageData.headerShow = true" :strokeWidth="2" :size="18" />
                </a-divider>
            </div>
            <div class="my-tool-bar">
                <Toolbar :items="titelisLbs" @add="addHandler" @del="" @select="selectHandler" @xzlld="xzllds"
                    @xinzhuojia="xinzhuojias" @handle="handle" @audit="audit">
                </Toolbar>
            </div>
        </template>
        <template #pageTabel>
            <a-tabs   :lazy-load="true" :justify="true" default-active-key="1" @change="tabChange">
                <a-tab-pane title="待处理" key="1">
                    <AgGridVuesCopys :rowHeight="33" :headerHeight="33" :suppressCopyRowsToClipboard="true" rowSelection="multiple" @grid-ready="gridReady"
                        style="height:100%" :defaultColDef="defaultColDef2" class='ag-theme-alpine'
                        :rowData="table.dataList" :columnDefs="tc2" :localeText="localeText1"></AgGridVuesCopys>
                </a-tab-pane>
                <a-tab-pane title="已处理" key="2">
                    <AgGridVuesCopys :rowHeight="33" :headerHeight="33" :suppressCopyRowsToClipboard="true" rowSelection="multiple" @grid-ready="gridReady"
                        style="height:100%" :defaultColDef="defaultColDef" class='ag-theme-alpine' :rowData="table.dataList"
                        :columnDefs="tc" :localeText="localeText1"></AgGridVuesCopys>
                </a-tab-pane>
            </a-tabs>
        </template>
        <paginationCopys :total="total" show-total show-jumper show-page-size @change="PageSize" @page-size-change="change1"
            style="justify-content: center" :page-size="size" :current="page" />
        <a-drawer ok-text='保存' cancel-text='关闭' :style="{ 'zIndex': 999 }" :mask-closable="false" :height="600"
            :visible="pageData.showAdd" unmountOnClose @ok="sicksOk" placement="bottom" @cancel="sicksNo">
            <template #title>
                {{ pageData.sideTitle }}
            </template>
            <div>
                <a-space>
                    <a-button size="mini" type="primary" @click="tjWlzl"
                        v-if="pageData.sideTitle != '新增出库单(布笼)'">添加</a-button>
                </a-space>
                <div style="height:10px ;"></div>
                <a-table :style="{
                    height: '100%',
                    marginTop: '10px'
                }" stripe :bordered="true" :scrollbar="true" :pagination="false" sticky-header :columns="tableColumns"
                    :data="tableSjList">
                    <template v-for="(item, index) in tableColumns" #[item.slotName]="{ record }">
                        <div v-if="(item.ls != '' && item.dropState == 1)">
                            <a-select popup-container="html"  class="bacClass" v-model="record[item.slotName]" allow-clear
                                @click="dongTypeSelce(record, item)" @change="changsType(item, record)">
                                <a-option v-for="items in isDtas" :value="items[item.slotName]">
                                    {{ items[(item.slotName)] }}
                                </a-option>
                            </a-select>
                        </div>
                        <div
                            v-else-if="(item.ls != '' && item.dropState == 0 && item.slotName != 'pieceNumber' && item.slotName != 'bulkNumber' && item.slotName != 'bulkWeight' && item.slotName != 'pieceWeight')">
                            <a-input disabled v-if="item.slotName != 'totalNum'" v-model="record[item.slotName]"></a-input>
                            <a-input-number disabled v-if="item.slotName == 'totalNum'" :precision="2"
                                v-model="record[item.slotName]"></a-input-number>
                        </div>
                        <div v-else-if="(item.ls == '' || item.ls == undefined && index != tableColumns.length - 1)">
                            <a-input
                                v-if="item.slotName == 'firm' || item.slotName == 'warehouseName' || item.slotName == 'warehouseTypeName'"
                                disabled v-model="record[item.slotName]"></a-input>
                            <a-input class="bacClass"
                                v-else-if="item.slotName != 'firm' && item.slotName != 'warehouseName' && item.slotName != 'warehouseTypeName' && item.slotName != 'pieceNumber' && item.slotName != 'bulkNumber' && item.slotName != 'bulkWeight' && item.valueType == 0"
                                v-model="record[item.slotName]"></a-input>
                            <a-input-number class="bacClass"
                                v-else-if="item.slotName != 'firm' && item.slotName != 'warehouseName' && item.slotName != 'warehouseTypeName' && item.slotName != 'pieceNumber' && item.slotName != 'bulkNumber' && item.slotName != 'bulkWeight' && item.valueType == 1"
                                v-model="record[item.slotName]" :min="1"></a-input-number>
                            <a-input-number class="bacClass"
                                v-else-if="item.slotName != 'firm' && item.slotName != 'warehouseName' && item.slotName != 'warehouseTypeName' && item.slotName != 'pieceNumber' && item.slotName != 'bulkNumber' && item.slotName != 'bulkWeight' && item.valueType == 2"
                                v-model="record[item.slotName]" :precision="2"></a-input-number>
                            <a-input-number class="bacClass"
                                v-else-if="item.slotName != 'firm' && item.slotName != 'warehouseName' && item.slotName != 'warehouseTypeName' && item.slotName == 'pieceNumber'"
                                v-model="record['pieceNumber']" @change="pieceNumbers($event, record)"></a-input-number>
                            <a-input-number class="bacClass"
                                v-else-if="item.slotName != 'firm' && item.slotName != 'warehouseName' && item.slotName != 'warehouseTypeName' && item.slotName == 'bulkNumber'"
                                v-model="record['bulkNumber']" @change="bulkNumbers($event, record)"></a-input-number>
                            <a-input-number class="bacClass"
                                v-else-if="item.slotName != 'firm' && item.slotName != 'warehouseName' && item.slotName != 'warehouseTypeName' && item.slotName == 'bulkWeight'"
                                v-model="record['bulkWeight']" :precision="2"
                                @change="bulkWeights($event, record)"></a-input-number>
                        </div>
                        <div v-else-if="(index != tableColumns.length - 1)">
                            <a-input-number class="bacClass" v-if="item.slotName == 'pieceWeight'"
                                v-model="record['pieceWeight']" :precision="2"
                                @change="pieceWeights($event, record)"></a-input-number>
                        </div>
                        <a-button v-if="index == tableColumns.length - 1 && pageData.sideTitle != '新增出库单(布笼)'"
                            type="outline" size="mini" @click="deletWhsWl(record)">
                            <template #icon>
                                <icon-delete />
                            </template>
                            删除
                        </a-button>
                    </template>
                </a-table>
            </div>
        </a-drawer>
        <a-modal v-model:visible="visible" title="详情" :width="1200" :footer="false" :draggable="true">
            <a-table :style="{
                height: '500px',
                marginTop: '10px'
            }" stripe :bordered="true" :scrollbar="true" sticky-header :pagination="false" :columns="tableColumns1"
                :data="whListMingxs">
            </a-table>
        </a-modal>
        <a-modal v-model:visible="visiblecg" ok-text="打印" @ok="print" @cancel="cancels" :width="1200">
            <template #title>
                出库单打印
            </template>
            <div id="deliverylist">
                <div id="dys">
                    <QrcodeVue :value="qrData.code"></QrcodeVue>
                    <div>
                        <p>打印人:&nbsp;&nbsp;{{ qrData.dyData }}</p>
                        <p>打印时间:&nbsp;&nbsp;{{ qrData.dyTime }}</p>
                        <p>单号:&nbsp;&nbsp;{{ qrData.dyCode }}</p>
                    </div>
                </div>
                <table class="isTable">
                    <tr>
                        <th v-for=" item in btList">{{ item.chineseName }}</th>
                        <!-- <th v-for=" item in btList">{{ item[Object.keys(item)[0]] }}</th> -->
                    </tr>
                    <tr v-for="items in jsList">
                        <td v-for="item in btList">{{ items[item.englishName] }}</td>
                    </tr>
                </table>
            </div>
        </a-modal>

        <a-modal :width="1200" v-model:visible="visibleYl" :on-before-ok="handleOks" @cancel="handleCancels"
            :mask-closable='false'>
            <template #title>
                {{ titelTjs }}
            </template>
            <div class="cgisDatas">
                <div>
                    <span>单据编号:</span><a-input class="bacClass" v-model="isLyNodeCodeds" :style="{ width: '150px' }"
                        allow-clear />
                </div>
                <div v-if="titelTjs == '原纱仓库存'">
                    <span>原料编号:</span><a-input class="bacClass" v-model="isLyCodeds" :style="{ width: '150px' }"
                        allow-clear />
                </div>
                <div v-if="titelTjs == '原纱仓库存'">
                    <span>原料名称:</span><a-input class="bacClass" v-model="isLyNameds" :style="{ width: '150px' }"
                        allow-clear />
                </div>
                <div v-if="titelTjs == '原纱仓库存'">
                    <span>批次:</span><a-input class="bacClass" v-model="ptisCs" :style="{ width: '150px' }" allow-clear />
                </div>
                <div v-if="titelTjs == '五金仓库存'">
                    <span>物料编号:</span><a-input class="bacClass" v-model="isWlCodeds" :style="{ width: '150px' }"
                        allow-clear />
                </div>
                <div v-if="titelTjs == '五金仓库存'">
                    <span>物料名称:</span><a-input class="bacClass" v-model="isWlNameds" :style="{ width: '150px' }"
                        allow-clear />
                </div>
                <a-button type="primary" size="mini" @click="cxCgsLists">查询</a-button>
            </div>
            <a-table :style="{
                height: '500px',
                marginTop: '10px'
            }" :row-selection="{ showCheckedAll: true, width: 50, onlyCurrent: true }" rowKey="id"
                v-model:selected-keys="selectedRowKeys2" stripe :bordered="true" :scrollbar="true" sticky-header
                :pagination="{ size: 'mini', current: paginations.page, pageSize: 30, total: paginations.total }"
                :columns="tableColumns3" :data="wlListXqs">
            </a-table>
        </a-modal>
        <a-modal :width="1200" v-model:visible="visibleCg" :on-before-ok="handleOk" @cancel="handleCancels2"
            :mask-closable='false'>
            <template #title>
                选择领料单
            </template>
            <div class="cgisDatas">
                <div>
                    <span>领料单号:</span>
                    <a-select popup-container="html"  class="bacClass" v-model="lingLiaoDanhao" :style="{ width: '150px' }"
                        @search="lingLiaoDanhaoLists" @click="lingLiaoDanhaoList" allow-search allow-clear>
                        <a-option v-for="item in lingLiaoDanArray">{{ item.planMaterialCode }}</a-option>
                    </a-select>
                    <!-- <a-input class="bacClass" v-model="lingLiaoDanhao" :style="{ width: '150px' }" allow-clear /> -->
                </div>
                <div>
                    <span>原料编号:</span>
                    <a-select popup-container="html"  class="bacClass" v-model="yuanLiaobianhao" :style="{ width: '150px' }"
                        @search="yuanLiaobianhaoLists" @click="yuanLiaobianhaoList" allow-search allow-clear>
                        <a-option v-for="item in lingLiaoDanArray">{{ item.rawmaterialCode }}</a-option>
                    </a-select>
                    <!-- <a-input class="bacClass" v-model="yuanLiaobianhao" :style="{ width: '150px' }" allow-clear /> -->
                </div>
                <div>
                    <span>原料名称:</span>
                    <a-select popup-container="html"  class="bacClass" v-model="yuanLiaoName" :style="{ width: '150px' }"
                        @search="yuanLiaoNameLists" @click="yuanLiaoNameList" allow-search allow-clear>
                        <a-option v-for="item in lingLiaoDanArray">{{ item.rawmaterialName }}</a-option>
                    </a-select>
                    <!-- <a-input class="bacClass" v-model="yuanLiaoName" :style="{ width: '150px' }" allow-clear /> -->
                </div>
                <a-button type="primary" size="mini" @click="cxCgsList">查询</a-button>
            </div>
            <a-table :style="{
                height: '500px',
                marginTop: '10px'
            }" :row-selection="{ showCheckedAll: true, width: 50, onlyCurrent: true }" rowKey="planMaterialId"
                v-model:selected-keys="selectedRowKeys1" stripe :bordered="true" :scrollbar="true" sticky-header
                :pagination="false" :columns="tableColumns2" :data="cgListXqs">
            </a-table>
            <paginationCopys :style="{ marginTop: '10px' }" :total="total2" show-total show-jumper show-page-size
                @change="PageSize2" @page-size-change="change12" style="justify-content: center" />
        </a-modal>
        <a-modal v-model:visible="visible2" :on-before-ok="handleOk2" @cancel="handleCancel2">
            <a-table :style="{
                height: '500px',
                marginTop: '10px'
            }" :row-selection="{ showCheckedAll: true, width: 50, onlyCurrent: true }" rowKey="shelveName"
                v-model:selected-keys="selectedRowKeys12" stripe :bordered="true" :scrollbar="true" sticky-header
                :pagination="false" :columns="tableColumns22" :data="cgListXqs2">
                <template #save="{ record }">
                    <a-button size="mini" status="success" @click="xingqs(record)">详情</a-button>
                </template>
            </a-table>
        </a-modal>
        <a-modal v-model:visible="visible3" :hide-cancel="true" :width="1200">
            <a-table :style="{
                height: '500px',
                marginTop: '10px'
            }" stripe :bordered="true" :scrollbar="true" sticky-header :pagination="false" :columns="tableColumns4"
                :data="cgListXqs22">
            </a-table>
        </a-modal>
    </PageTabelLayout>
</template>

<script lang="ts">
import { post, get } from "@/api/http";
import {
    useTable,
    useRowKey,
    useTableColumn,
    usePagination,
    useRowSelection,
} from "@/hooks/table";

import { ref, reactive, h, watch } from "vue";
import Toolbar from "@/components/Toolbar.vue";

import PageTabelLayout from "@/components/pageTabelLayout.vue";
import TreeUtils from "@/utils/TreeUtils";

import WHService, { Warhouse, CompanyList, WhTypeField } from '@/service/wh'
import { Message, Modal } from "@arco-design/web-vue";
import { IconDoubleUp, IconDoubleDown, IconEdit, IconFindReplace, IconDelete } from "@arco-design/web-vue/es/icon";
import pagination from "@arco-design/web-vue/es/pagination";
import { table } from "console";
import QrcodeVue from 'qrcode.vue'
import printJS from 'print-js'


import { localeText } from '@/api/aggridZw'

export default {
    name: "OrderDeliveryList",

    setup() {

        const whService = new WHService()
        const whService1 = new WHService()
        const whService2 = new WHService()
        const whList = ref<any[]>([])
        const whTypeList = whService.whTypeList

        const whTypeFieldList = whService.whTypeFieldList
        const whTypeFieldList1 = whService1.whTypeFieldList
        const whTypeFieldList2 = whService2.whTypeFieldList
        const treeUtils = new TreeUtils()
        const companyList: any = whService.companyList
        const searchData = reactive<{
            whTypeName: string;
            firm: string,
            wh: string,
            stats: any
        }>({
            firm: '',
            whTypeName: "",
            wh: '',
            stats: null
        });

        const baseCol: any[] = [{
            dataIndex: 'orderNo',
            key: 'orderNo',
            title: '单据编号',
            width: 180
        }, {
            dataIndex: 'firm',
            key: 'firm',
            title: '公司',
            width: 150
        }, {
            dataIndex: 'warehouseTypeName',
            key: 'warehouseTypeName',
            title: '仓库类型',
            width: 150
        },
        {
            dataIndex: 'warehouseName',
            key: 'warehouseName',
            title: '仓库',
            width: 150
        }
            , {
            dataIndex: 'auditName',
            key: 'auditName',
            title: '审核人',
            width: 100
        }, {
            title: '审核时间',
            dataIndex: 'auditTime',
            key: 'auditTime',
            width: 100
        },
        {
            title: '创建人',
            dataIndex: 'createName',
            key: 'createName',
            width: 150
        },
        {
            title: '创建时间',
            dataIndex: 'createTime',
            key: 'createTime',
            width: 150
        },
        {
            title: '修改人',
            dataIndex: 'updateName',
            key: 'updateName',
            width: 150
        },
        {
            title: '修改时间',
            dataIndex: 'updateTime',
            key: 'updateTime',
            width: 150
        },
        {
            title: '单据状态',
            dataIndex: 'infoState',
            key: 'infoState',
            slotName: 'infoState',
            fixed: "right",
            width: 150
        },
        {
            title: '审核状态',
            dataIndex: 'auditState',
            slotName: 'auditState',
            width: 100,
            key: 'auditState',
            fixed: "right",
        },
        {
            title: '详情',
            fixed: "right",
            slotName: 'action',
            width: 280
        }]

        const total = ref(0);
        const page = ref(1);
        const size = ref(10);
        function PageSize(val: any) {
            page.value = val
            doRefresh();
        }
        function change1(val: any) {
            size.value = val
            doRefresh();
        }

        function doRefresh() {
            pageData.pageLoading = true;
            if (tabKey.value == 1) {
                if (searchData.wh == undefined || searchData.wh == null || searchData.wh == "") {
                    Message.error('请先选择主页仓库类型或选择公司或仓库')

                } else {
                    let isWhId;
                    whList.value.forEach((item: any) => {
                        if (searchData.wh == item.warehouseName) {
                            isWhId = item.id
                        }
                    })
                    post({
                        url: "wms/WjController/getWjPendingInfo",
                        data: {
                            "page": page.value,
                            "size": size.value,
                            // "warehouseTypeName": searchData.whTypeName,
                            "firmId": searchData.firm,
                            "code": pageData['code'],
                            'materialName': pageData['materialName'],
                            'startTime': pageData['requisitionTime'][0],
                            'endTime': pageData['requisitionTime'][1],
                            warehouseId: isWhId
                        },
                    })
                        .then(({ data, code }: any) => {
                            if (code === 200) {
                                table.handleSuccess(data.list);
                                gridOption.value.setRowData(data.list);
                                pagination.setTotalSize(data.total);
                                total.value = data.total
                            }
                        })
                        .catch(console.log).finally(() => {
                            pageData.pageLoading = false;
                        });
                }

            } else {
                post({
                    url: "wms/WarehousetypeFieldvalue/getInvoicesByPage",
                    data: {
                        "page": page.value,
                        "size": size.value,
                        "warehouseTypeName": searchData.whTypeName,
                        "firmId": searchData.firm,
                        "infoType": 2,
                        'infoState': searchData.stats,
                        warehouseName: searchData.wh
                    },
                })
                    .then(({ data, code }: any) => {
                        if (code === 200) {
                            table.handleSuccess(data.list);
                            gridOption.value.setRowData(data.list);
                            pagination.setTotalSize(data.total);
                            total.value = data.total
                        }
                    })
                    .catch(console.log).finally(() => {
                        pageData.pageLoading = false;
                    });
            }

        }



        const { selectedRowKeys, onSelectionChange } = useRowSelection();
        const pagination = usePagination(doRefresh);
        const table = useTable();
        const rowKey = useRowKey("id");
        let tableColumns: any = ref([])
        let tableColumns3: any = ref([])
        let tableColumns1: any = ref([])
        let tableListDatas = reactive({
            typeLesIds: 0
        })
        watch(() => whService.whTypeFieldList.value, () => {
            //  baseCol.splice(3,0, ...(whService.whTypeFieldList.value.map((f:any)=>{
            //     return {
            //         dataIndex:f.extendField,
            //         key:f.extendField,
            //         title:f.fieldName,
            //         width:150
            //     }
            // })))

            tableColumns1.value = whService.whTypeFieldList.value.map((f: any) => {
                if (f.englishName == 'rawMaterialName') {
                    return {
                        dataIndex: f.englishName,
                        key: f.englishName,
                        title: f.chineseName,
                        slotName: f.englishName,
                        width: 450,
                    }
                } else if (f.englishName == 'rawMaterialCode') {
                    return {
                        dataIndex: f.englishName,
                        key: f.englishName,
                        title: f.chineseName,
                        slotName: f.englishName,
                        width: 200,
                    }
                } else if (f.englishName == 'sourceOrderNo') {
                    return {
                        dataIndex: f.englishName,
                        key: f.englishName,
                        title: f.chineseName,
                        slotName: f.englishName,
                        width: 200,
                    }
                } else if (f.englishName == 'planMaterialCode') {
                    return {
                        dataIndex: f.englishName,
                        key: f.englishName,
                        title: f.chineseName,
                        slotName: f.englishName,
                        width: 200,
                    }
                } else {
                    return {
                        dataIndex: f.englishName,
                        key: f.englishName,
                        title: f.chineseName,
                        slotName: f.englishName,
                        width: 150,
                    }
                }
            })
            if (pageData.sideTitle != '新增出库单(布笼)') {
                tableColumns.value = whService.whTypeFieldList.value.map((f: any) => {
                    return {
                        dataIndex: f.englishName,
                        key: f.englishName,
                        title: f.chineseName,
                        slotName: f.englishName,
                        width: 150,
                        ls: f.ls,
                        dropState: f.dropState,
                        conditions: f.conditions,
                        valueType: f.valueType,
                        mustState: f.mustState
                    }
                })
                tableColumns.value.push(
                    {
                        title: '操作',
                        fixed: "right",
                        slotName: 'action',
                        width: 150
                    }
                )
            } else {
                tableColumns.value = whService.whTypeFieldList.value.map((f: any) => {
                    return {
                        dataIndex: f.englishName,
                        key: f.englishName,
                        title: f.chineseName,
                        slotName: f.englishName,
                        width: 150,
                        ls: '0',
                        dropState: 0,
                        conditions: f.conditions,
                        valueType: f.valueType,
                        mustState: 0
                    }
                })
            }
            whService.whTypeFieldList.value.forEach((item: any) => {
                tableListDatas[item.englishName] = ''
            })


        })

        watch(() => whService1.whTypeFieldList.value, () => {
            tableColumns3.value = whService1.whTypeFieldList.value.map((f: any) => {
                if (f.englishName == 'rawMaterialName') {
                    return {
                        dataIndex: f.englishName,
                        key: f.englishName,
                        title: f.chineseName,
                        slotName: f.englishName,
                        width: 450,
                    }
                } else if (f.englishName == 'rawMaterialCode') {
                    return {
                        dataIndex: f.englishName,
                        key: f.englishName,
                        title: f.chineseName,
                        slotName: f.englishName,
                        width: 200,
                    }
                } else {
                    return {
                        dataIndex: f.englishName,
                        key: f.englishName,
                        title: f.chineseName,
                        slotName: f.englishName,
                        width: 150,
                    }
                }
            })
            tableColumns3.value.unshift({
                dataIndex: 'orderNo',
                key: 'orderNo',
                title: '单据编号',
                width: 180
            }
            )

        })


        const pageData = reactive<{
            showAdd: boolean
            sideTitle: string
            pageLoading: boolean
            headerShow: boolean
            code: any
            materialName: any
            requisitionTime: any[]
        }>({
            showAdd: false,
            sideTitle: "新增出库单",
            pageLoading: false,
            headerShow: true,
            code: undefined,
            materialName: undefined,
            requisitionTime: []
        })

        const addHandler = () => {
            if (searchData.whTypeName == '' || searchData.wh == '' || searchData.firm == '') {
                Message.error('请先选择主页仓库类型或选择公司或仓库')
            } else {
                let isWhId;
                whList.value.forEach((item: any) => {
                    if (searchData.wh == item.warehouseName) {
                        isWhId = item.id
                    }
                })
                whService.loadWHTypeFieldList({ warehouseId: isWhId, showType: 2 })
                pageData.sideTitle = '新增出库单'
                pageData.showAdd = true
            }
        }
        const selectHandler = () => {
            if (searchData.whTypeName == '' || searchData.wh == '' || searchData.firm == '') {
                Message.error('请先选择主页仓库类型或选择公司或仓库')
            } else {
                page.value = 1
                doRefresh()
            }
        }
        const titelisLbs: any = ref([])
        const whChange = (val: any) => {
            if (val == '原纱仓' && tabKey.value == 2) {
                titelisLbs.value = ['新增(领料单)', '查询', '新增', '审核']
            } else if (val == '坯布仓' && tabKey.value == 2) {
                titelisLbs.value = ['新增(布笼)', '查询', '新增', '审核']
            } else if (tabKey.value == 2) {
                titelisLbs.value = ['查询', '新增', '审核']
            } else if (val == '五金仓' && tabKey.value == 1) {
                titelisLbs.value = ['查询', '处理']
            }

            whList.value = []
            searchData.wh = ''
            searchData.firm = ''
        }
        watch(() => whService.whList.value, (o, n) => {


            whList.value = whService.whList.value
        })
        const companyChange = (val: any) => {
            whList.value = []
            searchData.wh = ''
            whService.getWarhouseList(searchData.firm, searchData.whTypeName)
        }

        let visible = ref(false)
        let whListMingxs = ref<any[]>([])
        const isXiang = async (val: any) => {
            const res: any = await whService.getWarhouseMinxList(val.orderNo, val.warehouseTypeName, val.warehouseName, val.firmId)
            if (res.code == 200) {
                whListMingxs.value = res.data
                visible.value = true
            }
        }
        let tableSjList: any = ref([])
        const tjWlzl = () => {
            // tableListDatas.typeLesIds++
            // tableSjList.value.push(JSON.parse(JSON.stringify(tableListDatas)))
            // tableSjList.value.forEach((item: any) => {
            //     item['warehouseTypeName'] = searchData.whTypeName
            //     item['warehouseName'] = searchData.wh
            //     item['firmId'] = searchData.firm
            //     companyList.value.forEach((items: any) => {
            //         if (items.id == searchData.firm) {
            //             item['firm'] = items.typeName ? items.typeName + '-' + items.firmName : items.firmName
            //         }
            //     })
            //     item['infoType'] = 2
            // })
            // 选择原料库存searchData.wh
            titelTjs.value = searchData.wh + '库存'
            let isWhId;
            whList.value.forEach((item: any) => {
                if (searchData.wh == item.warehouseName) {
                    isWhId = item.id
                }
            })
            whService1.loadWHTypeFieldList({ warehouseId: isWhId, showType: 0 })
            visibleYl.value = true
        }
        const sicksOk = async () => {
            if (tableSjList.value.length == 0) {
                Message.error('请先新增入库数据')
                return false
            }
            for (let i = 0; i < tableSjList.value.length; i++) {
                var o = tableSjList.value[i]
                for (let j = 0; j < tableColumns.value.length; j++) {
                    var item = tableColumns.value[j]
                    if (item.mustState == 1) {
                        if (item.valueType == 0) {
                            if (o[item.slotName] == '' || o[item.slotName] == undefined || o[item.slotName] == null) {
                                Message.error(item.title + '必填不能为空')
                                return false
                            }
                        } else {
                            // 数字大于0
                            if (o[item.slotName] == '' || o[item.slotName] == undefined || o[item.slotName] == null || o[item.slotName] <= 0) {
                                Message.error(item.title + '必填并且大于0')
                                return false
                            }
                        }
                    }
                }
            }
            tableListDatas.typeLesIds = 0
            if (pageData.sideTitle == '新增出库单') {
                const res: any = await whService.addWarhouseMinxList(tableSjList.value)
                if (res.code == 200) {
                    tableSjList.value = []
                    doRefresh()
                    Message.success('添加成功')
                    pageData.showAdd = false
                } else {
                    Message.error(res.message)
                }
            } else if (pageData.sideTitle == '新增出库单(布笼)') {
                tableSjList.value.forEach((item: any) => {
                    item['shelveMark'] = 1
                })
                const res: any = await whService.addWarhouseMinxList(tableSjList.value)
                if (res.code == 200) {
                    tableSjList.value = []
                    doRefresh()
                    Message.success('添加成功')
                    pageData.showAdd = false
                } else {
                    Message.error(res.message)
                }
            }
            else if (pageData.sideTitle == '修改出库单') {
                tableSjList.value.forEach((item: any) => {
                    item['warehouseTypeName'] = searchData.whTypeName
                    item['warehouseName'] = searchData.wh
                    item['firmId'] = searchData.firm
                    companyList.value.forEach((items: any) => {
                        if (items.id == searchData.firm) {
                            item['firm'] = items.typeName ? items.typeName + '-' + items.firmName : items.firmName
                        }
                    })
                    item['infoType'] = 2
                    item['orderNo'] = orderNos
                    item['createName'] = tableSjList.value[0].createName
                    item['createTime'] = tableSjList.value[0].createTime
                })
                let updataWhdataList = {
                    warehouseTypeName: searchData.whTypeName,
                    warehouseName: searchData.wh,
                    firmId: searchData.firm,
                    updateInfo: tableSjList.value
                }
                const res: any = await whService.updataWarhouseMinxList(updataWhdataList)
                if (res.code == 200) {
                    orderNos = ''
                    tableSjList.value = []
                    doRefresh()
                    Message.success('修改成功')
                    pageData.showAdd = false
                } else {
                    Message.error(res.message)
                }
            }
        }
        const sicksNo = () => {
            tableListDatas.typeLesIds = 0
            tableSjList.value = []
            pageData.showAdd = false
        }
        let orderNos: any;
        const xingXg = async (val: any) => {
            orderNos = val.orderNo
            const res = await whService.getWarhouseMinxList(val.orderNo, val.warehouseTypeName, val.warehouseName, val.firmId)
            if (res.code == 200) {
                tableSjList.value = res.data
                pageData.sideTitle = '修改出库单'
                pageData.showAdd = true
            }
        }

        const deletWh = (val: any) => {
            let objDelet = {
                warehouseTypeName: val.warehouseTypeName,
                warehouseName: val.warehouseName,
                firmId: val.firmId,
                delOrderNoInfo: [val.orderNo]
            }
            Modal.confirm({
                title: '系统提示',
                content: '确认删除选中的数据?',
                onOk: async () => {
                    const res: any = await whService.deletWarhouseMinxList(objDelet)
                    if (res.code == 200) {
                        Message.success('删除成功')
                        doRefresh()
                    } else {
                        Message.error(res.message)
                    }
                }
            })
        }
        const deletWhsWl = (val: any) => {
            let objDelet = {
                warehouseTypeName: val.warehouseTypeName,
                warehouseName: val.warehouseName,
                firmId: val.firmId,
                delInfo: [val.id]
            }
            Modal.confirm({
                title: '系统提示',
                content: '确认删除选中的数据?',
                onOk: async () => {
                    if (val.id == undefined) {
                        tableSjList.value.forEach((item: any, index: any) => {
                            if (val.typeLesIds == item.typeLesIds) {
                                tableSjList.value.splice(index, 1)
                            }
                        })
                        if (tableSjList.value.length == 0) {
                            pageData.showAdd = false
                        }
                    } else {
                        const res: any = await whService.deletWhmxWarhouseMinxList(objDelet)
                        if (res.code == 200) {
                            Message.success('删除成功')
                            const resz: any = await whService.getWarhouseMinxList(val.orderNo, val.warehouseTypeName, val.warehouseName, val.firmId)
                            if (resz.code == 200) {
                                if (resz.data.length == 0) {
                                    whListMingxs.value = resz.data
                                    tableSjList.value = resz.data
                                    doRefresh()
                                    pageData.showAdd = false
                                } else {
                                    whListMingxs.value = resz.data
                                    tableSjList.value = resz.data
                                }
                            }
                        } else {
                            Message.error(res.message)
                        }
                    }
                }
            })
        }
        const visiblecg = ref(false)
        const zsList: any = ref([])
        const btList: any = ref<any[]>([])
        const jsList: any = ref([])
        const qrData = reactive({
            dyTime: '',
            dyData: '',
            dyCode: '',
            code: ''
        })
        const dyingMx = async (val: any) => {
            let isDataObj = {
                "warehouseTypeName": val.warehouseTypeName,
                "warehouseName": val.warehouseName,
                "firmId": val.firmId,
                "orderNo": val.orderNo
            }
            const res: any = await whService.DyWhmxWarhouse([isDataObj])
            if (res.code == 200) {
                zsList.value = res.data
                qrData.dyTime = res.data[0].printTime
                qrData.dyData = res.data[0].printName
                qrData.dyCode = res.data[0].orderNo
                qrData.code = JSON.stringify({
                    warehouseCode: encodeURI(res.data[0].warehouseCode),
                    warehouseTypeCode: encodeURI(res.data[0].warehouseTypeCode),
                    orderNo: encodeURI(res.data[0].orderNo),
                    infoType: Number(2)
                })
                btList.value = res.data[0].tableHead
                // for (let item in res.data[0].tableHead) {
                //     btList.value.push({
                //         [item]: res.data[0].tableHead[item]
                //     })
                // }
                jsList.value = res.data[0].info
                visiblecg.value = true
            } else {
                Message.error(res.message)
            }
        }
        const print = () => {
            printJS({
                printable: 'deliverylist',
                type: 'html',
                targetStyles: ['*'],
            })
            zsList.value = []
            btList.value = []
            jsList.value = []
            for (let item in qrData) {
                qrData[item] = ''
            }
        }
        const cancels = () => {
            zsList.value = []
            btList.value = []
            jsList.value = []
            for (let item in qrData) {
                qrData[item] = ''
            }
        }
        let isDtas = ref([])
        const dongTypeSelce = async (record: any, val: any) => {
            var paramList: any = [];
            var ob: any = {};
            if (val.conditions.length > 0) {
                let conditions = val.conditions
                for (let i = 0; i < conditions.length; i++) {
                    if (conditions[i].extendField != null && conditions[i].extendField != "") {
                        if (record[conditions[i].extendField] == null || record[conditions[i].extendField] == "") {
                            let column = tableColumns.value.filter(function (o: any) {
                                return o.key == conditions[i].extendField;
                            })[0];
                            Message.error("请先输入" + column.title)
                            return;
                        } else {
                            ob[conditions[i].extendField] = record[conditions[i].extendField];
                        }
                    }
                }

            }
            ob["ls"] = val.ls;
            paramList.push(ob);
            const res = await whService.liusuiCkSmWhmxWarhouse(paramList)
            if (res.code == 200) {
                isDtas.value = res.data[val.ls]
            }
        }
        const changsType = (ob: any, record: any) => {
            if (record[ob.slotName] == "") {
                for (let key in isDtas.value[0]) {
                    record[key] = ""
                }
            } else {
                isDtas.value.forEach((item: any) => {
                    if (item[ob.slotName] == record[ob.slotName]) {
                        for (let key in item) {
                            record[key] = item[key]
                        }
                    }
                })
            }
        }
        const ckisPd = () => {
            if (searchData.whTypeName == '' || searchData.firm == '') {
                Message.error('请先选择仓库类型和所属工厂')
                return
            }
        }
        const isWhilist = (whName: any) => {
            let isWhId;
            whList.value.forEach((item: any) => {
                if (searchData.wh == item.warehouseName) {
                    isWhId = item.id
                }
            })
            whService.loadWHTypeFieldList({ warehouseId: isWhId, showType: 2 })
        }

        const visibleYl = ref(false)
        const handleOks = () => {
            if (selectedRowKeys2.value.length == 0) {
                Message.error('请勾选数据')
                return false
            }
            let islistArray: any = []
            selectedRowKeys2.value.forEach((v: any) => {
                wlListXqs.value.forEach((o: any) => {
                    if (v == o.id) {
                        islistArray.push(o)
                    }
                })
            })
            if (islistArray.length != 0) {
                for (let i = 0; i < islistArray.length; i++) {
                    tableSjList.value.push(islistArray[i])
                }

                tableSjList.value.forEach((item: any) => {
                    item['warehouseTypeName'] = searchData.whTypeName
                    item['warehouseName'] = searchData.wh
                    whList.value.forEach((items: any) => {
                        if (items.warehouseName == searchData.wh) {
                            item['warehouseId'] = items.id
                        }
                    })
                    item['firmId'] = searchData.firm
                    companyList.value.forEach((items: any) => {
                        if (items.id == searchData.firm) {
                            item['firm'] = items.typeName ? items.typeName + '-' + items.firmName : items.firmName
                        }
                    })
                    item['infoType'] = 2
                    delete item.PAGE_ROW_NUMBER
                    delete item.id
                    item['typeLesIds'] = tableListDatas.typeLesIds++
                    item['sourceOrderNo'] = item.orderNo
                    item['oldTotalNum'] = item.totalNum
                    delete item.orderNo
                })
                console.log(tableSjList.value)
                isLyCodeds.value = ''
                isLyNameds.value = ''
                isLyNodeCodeds.value = ''
                ptisCs.value = ''
                selectedRowKeys2.value = []
                wlListXqs.value = []
                visibleYl.value = false
                pageData.showAdd = true
                return true
            }

        }
        const handleCancels = () => {
            isLyCodeds.value = ''
            isLyNameds.value = ''
            isLyNodeCodeds.value = ''
            ptisCs.value = ''
            selectedRowKeys2.value = []
            wlListXqs.value = []
            visibleYl.value = false
        }
        const isLyCodeds = ref('')
        const isLyNameds = ref('')
        const isLyNodeCodeds = ref('')
        const titelTjs = ref('')
        const ptisCs = ref('')
        const cxCgsLists = () => {
            doRefreshs()
        }
        const wlListXqs = ref([])
        const selectedRowKeys2 = ref([])

        function doRefreshs() {
            post({
                url: "wms/WarehousetypeFieldvalue/getStockByPage",
                data: {
                    "page": paginations.page,
                    "size": 30,
                    "warehouseTypeName": searchData.whTypeName,
                    "warehouseName": searchData.wh,
                    "firmId": searchData.firm,
                    "orderNo": isLyNodeCodeds.value,
                    "rawMaterialCode": isLyCodeds.value,
                    "rawMaterialName": isLyNameds.value,
                    "materialCode": isWlCodeds.value,
                    "materialName": isWlNameds.value,
                    "batch": ptisCs.value,
                    "infoType": 0
                },
            })
                .then(({ data, code }: any) => {
                    if (code === 200) {
                        wlListXqs.value = data.list
                        pagination.setTotalSize(data.total);
                    }
                })
        }
        const paginations = usePagination(doRefreshs)
        const isWlCodeds: any = ref()
        const isWlNameds: any = ref()
        const gridOption = ref()
        const gridReady = (params: any) => {
            gridOption.value = params.api
        }
        const gridOption2 = ref()
        const gridReady2 = (params: any) => {
            gridOption2.value = params.api
        }

        const defaultColDef = {
            sortable: true,
            resizable: true,
            filter: true,
        }
        let tc: any[] = baseCol.map((o: any) => {

            let obj = {
                headerName: o.title,
                field: o.key,
                pinned: o['fixed'],
                width: 150
            }
            if (o.slotName === 'action') {
                obj['resizable'] = false
                obj['filter'] = false
                obj['sortable'] = false
                obj["lockPosition"] = "right"
                obj["width"] = 350
                obj['cellRenderer'] = {
                    template: `
                    <a-space>
                                <a-button v-if="isDtas.auditState === 0 && isDtas.shelveMark === 1" type="primary" size="mini" status="warning"
                                    @click="a1">
                                    <template #icon>
                                        <icon-edit />
                                    </template>
                                    修 改
                                </a-button>
                                <a-button v-else type="primary" size="mini" status="warning" disabled>
                                    <template #icon>
                                        <icon-edit />
                                    </template>
                                    修 改
                                </a-button>
                                <a-button type="primary" size="mini" @click="a2">
                                    <template #icon>
                                        <icon-archive />
                                    </template>
                                    打 印
                                </a-button>
                                <a-button type="outline" status="success" size="mini" @click="a3">
                                    <template #icon>
                                        <icon-find-replace />
                                    </template>
                                    详 情
                                </a-button>
                                <a-button type="outline" v-if="(isDtas.auditState == 0 || isDtas.auditState == 1)"
                                    size="mini" @click="a4">
                                    <template #icon>
                                        <icon-delete />
                                    </template>
                                    删 除
                                </a-button>
                                <a-button type="outline" v-else size="mini" disabled>
                                    <template #icon>
                                        <icon-delete />
                                    </template>
                                    删除
                                </a-button>
                            </a-space>

                    `,
                    setup(props: any) {
                        const isDtas = ref(props.params.data)
                        const a1 = () => {
                            xingXg(props.params.data)
                        }
                        const a2 = () => {
                            dyingMx(props.params.data)
                        }
                        const a3 = () => {
                            isXiang(props.params.data)
                        }
                        const a4 = () => {
                            deletWh(props.params.data)
                        }
                        return {
                            a1, a2, a3, a4, isDtas
                        }
                    }
                }
            }
            if (o.slotName === 'auditState') {
                obj['resizable'] = false
                obj['filter'] = false
                obj['sortable'] = false
                obj["lockPosition"] = "right"
                obj["width"] = 120
                obj['cellRenderer'] = {
                    template: `<a-button v-if="(isDatas.auditState == 0)" type="primary" status="warning" size="mini"
                                disabled>待&nbsp;审&nbsp;核&nbsp;
                            </a-button>
                            <a-button v-if="(isDatas.auditState == 2)" status="success" size="mini" disabled>审核通过
                            </a-button>
                            <a-button v-if="(isDatas.auditState == 1)" type="primary" size="mini" status="danger"
                                disabled>审核驳回
                            </a-button>`,
                    setup(props: any) {
                        const isDatas = ref(props.params.data)
                        return {
                            isDatas
                        }
                    }
                }
            }
            if (o.slotName === 'infoState') {
                obj['resizable'] = false
                obj['filter'] = false
                obj['sortable'] = false
                obj["lockPosition"] = "right"
                obj["width"] = 100
                obj['cellRenderer'] = {
                    template: `
                            <a-button v-if="(isDatas.infoState == 0)" status="success" size="mini" disabled>待出库
                            </a-button>
                            <a-button v-if="(isDatas.infoState == 1)" type="primary" size="mini" status="danger"
                                disabled>已出库
                            </a-button>`,
                    setup(props: any) {
                        const isDatas = ref(props.params.data)
                        return {
                            isDatas
                        }
                    }
                }
            }
            return obj
        })

        let a = [{
            showRowGroup: 'hide_def',
            "headerName": "",
            "checkboxSelection": true,
            "headerCheckboxSelection": true,
            "pinned": "left",
            "width": 50,
            resizable: false,
            filter: false,
            sortable: false,
            minWidth: 50,
            maxWidth: 50,
            lockPosition: "left",
        }]
        tc = a.concat(tc)
        const visibleCg = ref(false)
        const xzllds = () => {
            if (searchData.whTypeName == '' || searchData.wh == '' || searchData.firm == '') {
                Message.error('请先选择主页仓库类型或选择公司或仓库')
            } else {
                let isWhId: any;
                whList.value.forEach((item: any) => {
                    if (searchData.wh == item.warehouseName) {
                        isWhId = item.id
                    }
                })
                whService.loadWHTypeFieldList({ warehouseId: isWhId, showType: 2 })
                visibleCg.value = true
            }
        }
        const tableColumns2 = [{
            title: '领料单号',
            dataIndex: 'planMaterialCode',
            key: 'planMaterialCode',
            width: 150
        }, {
            title: '原料编号',
            dataIndex: 'rawMaterialCode',
            key: 'rawMaterialCode',
            width: 150
        }, {
            title: '原料名称',
            dataIndex: 'rawMaterialName',
            key: 'rawMaterialName',
            width: 150
        }, {
            title: '色号',
            dataIndex: 'colorNumber',
            key: 'colorNumber',
            width: 150
        },
        {
            title: '色称',
            dataIndex: 'colorName',
            key: 'colorName',
            width: 150
        },
        {
            title: '纱牌',
            dataIndex: 'brandName',
            key: 'brandName',
            width: 150
        },
        {
            title: '批次',
            dataIndex: 'batch',
            key: 'batch',
            width: 150
        },
        {
            title: '整件/件数',
            dataIndex: 'pieceNumber',
            key: 'pieceNumber',
            width: 150
        },
        {
            title: '整件/件重',
            dataIndex: 'pieceWeight',
            key: 'pieceWeight',
            width: 150
        },
        {
            title: '散件/件数',
            dataIndex: 'bulkNumber',
            key: 'bulkNumber',
            width: 150
        },
        {
            title: '散件/散重',
            dataIndex: 'bulkWeight',
            key: 'bulkWeight',
            width: 150
        },
        {
            title: '数量',
            dataIndex: 'totalNum',
            key: 'totalNum',
            width: 150
        }, {
            title: '单位',
            dataIndex: 'unit',
            key: 'unit',
            width: 150
        },
        ]
        const cgListXqs: any = ref([])
        const selectedRowKeys1: any = ref([])
        const cxCgsList = () => {
            doRefreshs2()
        }
        const lingLiaoDanhao: any = ref()
        const yuanLiaobianhao: any = ref()
        const yuanLiaoName: any = ref()
        const handleOk = async () => {
            if (selectedRowKeys1.value.length == 0) {
                Message.error('请勾选数据')
                return false
            }
            let islistArray: any = []
            let codeLists: any = []
            // rawMaterialCode
            selectedRowKeys1.value.forEach((v: any) => {
                cgListXqs.value.forEach((o: any) => {
                    if (v == o.planMaterialId) {
                        islistArray.push(o)
                        codeLists.push({
                            planMaterialCode: o.planMaterialCode,
                            rawmaterialCode: o.rawMaterialCode
                        })
                    }
                })
            })
            let isWhId;
            whList.value.forEach((item: any) => {
                if (searchData.wh == item.warehouseName) {
                    isWhId = item.id
                }
            })
            const res: any = await post({
                url: 'planSingle/planMaterial/getPlanMaterialListByCode',
                data: {
                    warehouseId: isWhId,
                    list: codeLists
                }
            })
            if (res.code == 200) {
                tableSjList.value = res.data
                tableSjList.value.forEach((item: any) => {
                    item['warehouseTypeName'] = searchData.whTypeName
                    item['warehouseName'] = searchData.wh
                    whList.value.forEach((items: any) => {
                        if (items.warehouseName == searchData.wh) {
                            item['warehouseId'] = items.id
                        }
                    })
                    item['firmId'] = searchData.firm
                    companyList.value.forEach((items: any) => {
                        if (items.id == searchData.firm) {
                            item['firm'] = items.typeName ? items.typeName + '-' + items.firmName : items.firmName
                        }
                    })
                    item['infoType'] = 2
                    item['typeLesIds'] = tableListDatas.typeLesIds++
                    item['oldTotalNum'] = item.totalNum
                    item['sourceOrderNo'] = item.orderNo

                    item['planMaterialId'] = item.planMaterialId
                    lingLiaoDanhao.value = ''
                    yuanLiaobianhao.value = ''
                    yuanLiaoName.value = ''
                    selectedRowKeys1.value = []
                    cgListXqs.value = []
                    visibleCg.value = false
                    pageData.showAdd = true
                    return true
                })
            } else {
                return false
                Message.error(res.message)
            }
        }
        const handleCancels2 = () => {
            lingLiaoDanhao.value = ''
            yuanLiaobianhao.value = ''
            yuanLiaoName.value = ''
            selectedRowKeys1.value = []
            cgListXqs.value = []
            visibleCg.value = false
        }
        const total2 = ref(10);
        const page2 = ref(1);
        const size2 = ref(10);
        function PageSize2(val: any) {
            page2.value = val
            doRefreshs2();
        }
        function change12(val: any) {
            size2.value = val
            doRefreshs2();
        }
        function doRefreshs2() {
            if (searchData.wh == '' || searchData.wh == null || searchData.wh == undefined) {
                Message.error('请先选择仓库')
                return
            }
            let isWhId;
            whList.value.forEach((item: any) => {
                if (searchData.wh == item.warehouseName) {
                    isWhId = item.id
                }
            })
            post({
                url: 'planSingle/planMaterial/getPlanMaterialListByWarehouse',
                data: {
                    page: page2.value,
                    size: size2.value,
                    planMaterialCode: lingLiaoDanhao.value,
                    rawmaterialCode: yuanLiaobianhao.value,
                    rawmaterialName: yuanLiaoName.value,
                    warehouseId: isWhId
                }
            }).then((res: any) => {
                if (res.code == 200) {
                    cgListXqs.value = res.data.data
                    total2.value = res.data.total
                } else {
                    Message.error(res.message)
                }
            })
        }
        const lingLiaoDanArray: any = ref([])
        const lingLiaoDanhaoList = () => {
            let isWhId;
            whList.value.forEach((item: any) => {
                if (searchData.wh == item.warehouseName) {
                    isWhId = item.id
                }
            })
            moHuCx({ key: 'planMaterialCode', value: lingLiaoDanhao.value, auditState: 1, warehouseId: isWhId })
        }
        const lingLiaoDanhaoLists = (val: any) => {
            let isWhId;
            whList.value.forEach((item: any) => {
                if (searchData.wh == item.warehouseName) {
                    isWhId = item.id
                }
            })
            moHuCx({ key: 'planMaterialCode', value: val, auditState: 1, warehouseId: isWhId })
        }
        const yuanLiaobianhaoList = () => {
            let isWhId;
            whList.value.forEach((item: any) => {
                if (searchData.wh == item.warehouseName) {
                    isWhId = item.id
                }
            })
            moHuCx({ key: 'rawmaterialCode', value: yuanLiaobianhao.value, auditState: 1, warehouseId: isWhId })
        }
        const yuanLiaobianhaoLists = (val: any) => {
            let isWhId;
            whList.value.forEach((item: any) => {
                if (searchData.wh == item.warehouseName) {
                    isWhId = item.id
                }
            })
            moHuCx({ key: 'rawmaterialCode', value: val, auditState: 1, warehouseId: isWhId })
        }
        const yuanLiaoNameList = () => {
            let isWhId;
            whList.value.forEach((item: any) => {
                if (searchData.wh == item.warehouseName) {
                    isWhId = item.id
                }
            })
            moHuCx({ key: 'rawmaterialName', value: yuanLiaoName.value, auditState: 1, warehouseId: isWhId })
        }
        const yuanLiaoNameLists = (val: any) => {
            let isWhId;
            whList.value.forEach((item: any) => {
                if (searchData.wh == item.warehouseName) {
                    isWhId = item.id
                }
            })
            moHuCx({ key: 'rawmaterialName', value: val, auditState: 1, warehouseId: isWhId })
        }
        function moHuCx(value: any) {
            post({
                url: 'planSingle/planMaterial/getFieldValue',
                data: value
            }).then((res: any) => {
                if (res.code == 200) {
                    lingLiaoDanArray.value = res.data
                } else {
                    Message.error(res.message)
                }
            })
        }
        const pieceNumbers = ($event: any, record: any) => {
            if ($event == null || $event == undefined || $event == '') {
                record['pieceNumber'] = 0
                record['totalNum'] = 0 * record['pieceWeight'] + record['bulkNumber'] * record['bulkWeight']
            } else {
                record['totalNum'] = $event * record['pieceWeight'] + record['bulkNumber'] * record['bulkWeight']
            }

        }
        const bulkNumbers = ($event: any, record: any) => {
            if ($event == null || $event == undefined || $event == '') {
                record['bulkNumber'] = 0
                record['totalNum'] = 0 * record['bulkWeight'] + record['pieceNumber'] * record['pieceWeight']
            } else {
                record['totalNum'] = $event * record['bulkWeight'] + record['pieceNumber'] * record['pieceWeight']
            }
        }
        const bulkWeights = ($event: any, record: any) => {
            if ($event == null || $event == undefined || $event == '') {
                record['bulkWeight'] = 0
                record['totalNum'] = 0 * record['bulkNumber'] + record['pieceNumber'] * record['pieceWeight']
            } else {
                record['totalNum'] = $event * record['bulkNumber'] + record['pieceNumber'] * record['pieceWeight']
            }
        }
        const pieceWeights = ($event: any, record: any) => {
            if ($event == null || $event == undefined || $event == '') {
                record['pieceWeight'] = 0
                record['totalNum'] = 0 * record['pieceNumber'] + record['bulkNumber'] * record['bulkWeight']
            } else {
                record['totalNum'] = $event * record['pieceNumber'] + record['bulkNumber'] * record['bulkWeight']
            }

        }

        const xinzhuojias = () => {
            let isWhId: any;
            whList.value.forEach((item: any) => {
                if (searchData.wh == item.warehouseName) {
                    isWhId = item.id
                }
            })
            post(
                {
                    url: 'wms/GreigeClothStock/getShelfByStock',
                    data: {
                        "warehouseId": isWhId
                    }
                }
            ).then((res: any) => {
                if (res.code == 200) {
                    pageData.sideTitle = '新增出库单(布笼)'
                    whService.loadWHTypeFieldList({ warehouseId: isWhId, showType: 2 })
                    cgListXqs2.value = res.data
                    visible2.value = true
                } else {
                    Message.error(res.message)
                }
            })
        }
        const visible2 = ref(false)
        const handleOk2 = async () => {
            if (selectedRowKeys12.value.length == 0) {
                Message.error('请勾选数据')
                return false
            }
            let isWhId;
            whList.value.forEach((item: any) => {
                if (searchData.wh == item.warehouseName) {
                    isWhId = item.id
                }
            })
            const res: any = await post({
                url: 'wms/GreigeClothStock/getShelfInfoByStock',
                data: {
                    "warehouseId": isWhId,
                    "shelveNameList": selectedRowKeys12.value
                }
            })
            if (res.code == 200) {
                tableSjList.value = res.data
                tableSjList.value.forEach((item: any) => {
                    item['warehouseTypeName'] = searchData.whTypeName
                    item['warehouseName'] = searchData.wh
                    whList.value.forEach((items: any) => {
                        if (items.warehouseName == searchData.wh) {
                            item['warehouseId'] = items.id
                        }
                    })
                    item['firmId'] = searchData.firm
                    companyList.value.forEach((items: any) => {
                        if (items.id == searchData.firm) {
                            item['firm'] = items.typeName ? items.typeName + '-' + items.firmName : items.firmName
                        }
                    })
                    item['infoType'] = 2
                    // delete item.id
                    item['typeLesIds'] = tableListDatas.typeLesIds++
                    item['sourceOrderNo'] = item.orderNo
                    item['oldTotalNum'] = item.totalNum

                })
                pageData.sideTitle = '新增出库单(布笼)'
                pageData.showAdd = true
                selectedRowKeys12.value = []
                return true
            } else {
                selectedRowKeys12.value = []
                Message.error(res.message)
            }
        }
        const handleCancel2 = () => {
            selectedRowKeys12.value = []
            visible2.value = false
        }
        const selectedRowKeys12 = ref([])
        const cgListXqs2 = ref([])
        const tableColumns22: any = ref([
            {
                title: "布笼",
                key: "shelveName",
                dataIndex: "shelveName",
                width: 150,
            },
            {
                title: '操作',
                dataIndex: 'save',
                slotName: 'save',
                fixed: 'right',
                width: 150,
            },
        ])
        const xingqs = (record: any) => {
            let isWhId;
            whList.value.forEach((item: any) => {
                if (searchData.wh == item.warehouseName) {
                    isWhId = item.id
                }
            })
            whService2.loadWHTypeFieldList({ warehouseId: isWhId, showType: 0 })
            post({
                url: 'wms/GreigeClothStock/getShelfInfoByStock',
                data: {
                    "warehouseId": isWhId,
                    "shelveNameList": [record.shelveName]
                }
            }).then((res: any) => {
                if (res.code == 200) {
                    cgListXqs22.value = res.data
                    visible3.value = true
                } else {
                    Message.error(res.message)
                }
            })
        }
        watch(() => whService2.whTypeFieldList.value, () => {
            tableColumns4.value = whService2.whTypeFieldList.value.map((f: any) => {
                //englishName: "grayName"
                if (f.englishName == "grayName" || f.englishName == 'rawMaterialInfo') {
                    return {
                        dataIndex: f.englishName,
                        key: f.englishName,
                        title: f.chineseName,
                        width: 450,
                    }
                } else {
                    return {
                        dataIndex: f.englishName,
                        key: f.englishName,
                        title: f.chineseName,
                        width: 150,
                    }
                }
            })
            tableColumns4.value.unshift({
                dataIndex: 'orderNo',
                key: 'orderNo',
                title: '单据编号',
                width: 180
            }
            )

        })
        const tableColumns4: any = ref([])
        const cgListXqs22: any = ref([])
        const visible3: any = ref(false)
        const localeText1: any = ref(localeText)
        //待处理数据
        const tableColumns5 = useTableColumn([
            {
                title: "领料单号",
                key: "code",
                dataIndex: "code",
                width: 150,
            },
            {
                title: "物料编号",
                key: "materialCode",
                dataIndex: "materialCode",
                width: 150,
            },

            {
                title: "物料名称",
                key: "materialName",
                dataIndex: "materialName",
                width: 150
            },
            {
                title: "领料数量",
                key: "num",
                dataIndex: "num",
                width: 150
            },
            {
                title: "单位",
                key: "unit",
                dataIndex: "unit",
                width: 200
            },
            {
                title: "创建人",
                key: "createName",
                dataIndex: "createName",
                width: 150
            },
            {
                title: "创建时间",
                key: "createTime",
                dataIndex: "createTime",
                width: 200
            },


        ]);
        let tc2: any[] = tableColumns5.map((o) => {

            let obj = {
                headerName: o.title,
                field: o.key,
                pinned: o['fixed']
            }
            obj['width'] = 250


            return obj
        })

        tc2 = a.concat(tc2)
        const defaultColDef2 = {
            sortable: true,
            resizable: true,
            filter: true,
            // flex: 1
        }
        //表格切换事件
        let tabKey = ref(1)
        function tabChange(key: any) {
            tabKey.value = key
            whChange(searchData.whTypeName)
        }

        //待处理页面的处理操作
        function handle() {
            if (gridOption2.value.getSelectedRows().length === 0) {
                Message.error('请先勾选');
                return
            }
            post({
                url: 'wms/GreigeClothStock/getShelfInfoByStock',
                data: {
                    "warehouseId": searchData.wh,
                    "pickList": gridOption2.value.getSelectedRows()
                }
            }).then((res: any) => {
                if (res.code == 200) {
                    doRefresh()
                } else {
                    Message.error(res.message)
                }
            })
        }
        //已处理数据审核
        function audit() {
            if (gridOption.value.getSelectedRows().length === 0) {
                Message.error('请先勾选');
                return
            }
            post({
                url: 'wms/GreigeClothStock/getShelfInfoByStock',
                data: {
                    "warehouseId": searchData.wh,
                    "pickList": gridOption.value.getSelectedRows()
                }
            }).then((res: any) => {
                if (res.code == 200) {
                    doRefresh()
                } else {
                    Message.error(res.message)
                }
            })
        }
        return {
            audit,
            tabKey,
            handle,
            tabChange,
            tc2,
            defaultColDef2,
            tableColumns5,
            gridReady2,
            localeText1,
            visible3,
            cgListXqs22,
            tableColumns4,
            xingqs,
            tableColumns22,
            cgListXqs2,
            selectedRowKeys12,
            handleCancel2,
            handleOk2,
            visible2,
            xinzhuojias,
            pieceWeights,
            bulkWeights,
            bulkNumbers,
            pieceNumbers,
            yuanLiaoNameLists,
            yuanLiaoNameList,
            yuanLiaobianhaoLists,
            yuanLiaobianhaoList,
            lingLiaoDanArray,
            lingLiaoDanhaoLists,
            lingLiaoDanhaoList,
            change12,
            PageSize2,
            total2,
            page2,
            size2,
            handleCancels2,
            handleOk,
            yuanLiaoName,
            yuanLiaobianhao,
            lingLiaoDanhao,
            cxCgsList,
            selectedRowKeys1,
            cgListXqs,
            tableColumns2,
            visibleCg,
            xzllds,
            titelisLbs,
            change1,
            PageSize,
            total,
            page,
            size,
            tc,
            defaultColDef,
            gridReady,
            gridOption,
            isWlNameds,
            isWlCodeds,
            titelTjs,
            ptisCs,
            paginations,
            isLyNodeCodeds,
            selectedRowKeys2,
            wlListXqs,
            cxCgsLists,
            isLyNameds,
            isLyCodeds,
            handleCancels,
            handleOks,
            visibleYl,
            isWhilist,
            ckisPd,
            changsType,
            isDtas,
            dongTypeSelce,
            qrData,
            cancels,
            zsList,
            btList,
            jsList,
            print,
            visiblecg,
            dyingMx,
            deletWhsWl,
            deletWh,
            xingXg,
            sicksNo,
            sicksOk,
            tableSjList,
            tableListDatas,
            tjWlzl,
            whListMingxs,
            isXiang,
            visible,
            companyChange,
            whChange,
            selectHandler,
            addHandler,
            companyList,
            whList,
            whTypeList,
            selectedRowKeys,
            whTypeFieldList,
            pagination,
            tableColumns,
            tableColumns1,
            table,
            rowKey,
            pageData,
            searchData,
            baseCol,
            whTypeFieldList1,
            whTypeFieldList2,
            tableColumns3
        };
    },
    components: { PageTabelLayout, QrcodeVue,  }
};
</script>
<style scoped lang="less">
.isTable {
    margin-top: 100px;
    width: 90%;
    margin: 0 auto;
    border: 1.2px solid #ccc;
    text-align: center;
    border-collapse: collapse;

    td {
        border: 1.2px solid #ccc;
    }

    th {
        border: 1.2px solid #ccc;
    }
}

#deliverylist {
    width: 100%;

    #dys {
        width: 90%;
        margin: 0 auto;
        display: flex;
        justify-content: space-between;
        font-size: 18px;
        font-weight: 600;
        margin-bottom: 20px;
    }
}

.cgisDatas {
    display: flex;
    justify-content: space-between;
}

// :deep(.arco-table-td-content) {
//     overflow: hidden;
//     white-space: nowrap;
//     text-overflow: ellipsis;
// }
</style>
